﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace GLYFrom
{
    public partial class YH_update : Form
    {
        public YH_update()
        {
            InitializeComponent();
        }
        int id = 0;
        public YH_update(int a)
        {
            id = a;
            InitializeComponent();
        }

        private void YH_update_Load(object sender, EventArgs e)
        {
            DataTable table=DBHelper.select(string.Format("select * from T_YongHu where YHId='{0}'",id));
            DataRow row=table.Rows[0];
            this.text_Name.Text=row["Name"].ToString();
            this.comboBox_Sex.Text=row["Sex"].ToString();
            this.text_ZhangHao.Text=row["ZhangHao"].ToString();
            this.text_MiMa.Text=row["MiMa"].ToString();
            this.text_DianHua.Text=row["DianHua"].ToString();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //修改数据
            string Name = this.text_Name.Text.Trim();
            string Sex = this.comboBox_Sex.Text.Trim();
            string ZhangHao = this.text_ZhangHao.Text.Trim();
            string MiMa = this.text_MiMa.Text.Trim();
            string DianHua = this.text_DianHua.Text.Trim();
            if (Name.Length > 0 && Sex.Length > 0 && ZhangHao.Length > 0 && MiMa.Length > 0 && DianHua.Length > 0)
            {
                int sr = DBHelper.ZSG(string.Format("update T_YongHu set Name='{0}',Sex='{1}',ZhangHao='{2}',MiMa='{3}',DianHua='{4}' where YHId='{5}'", Name, Sex, ZhangHao, MiMa, DianHua,id));
                if (sr > 0)
                {
                    MessageBox.Show("修改成功！");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("修改失败！");
                }
            }
            else
            {
                MessageBox.Show("修改失败,请填写完整！");
                return;
            }
        }
    }
}
